﻿using System;
using DataObject.Adv;

namespace KMT.Controls.Common
{
    public partial class Slider : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ListSlideShow();

                ListAdvMultiple();    
            }            
        }

        private void ListSlideShow()
        {
            var lstSlideShow = AdvController.Adv_GetAdvSlideShow();
            var count = lstSlideShow.Count;

            if (count > 0)
            {
                rptSlideShow.DataSource = lstSlideShow;
                rptSlideShow.DataBind();

                var html = string.Empty;
                for (int i = 0; i < count; i++)
                {
                    html += i == 0
                                ? string.Format("<span class=\"naviItem selected\">{0}</span>", i)
                                : string.Format("<span class=\"naviItem\">{0}</span>", i);
                }

                ltSlideShow.Text = html;
            }
        }

        private void ListAdvMultiple()
        {
            rptAdv.DataSource = AdvController.Adv_GetAdvMultiple();
            rptAdv.DataBind();
        }
    }
}